function [dist] = dist_dft(data,first_k)

data=fft(data');
data=data';
data=data(:,2:1+first_k);

[num_ts,dim]=size(data);

dist=zeros(num_ts);

for i=1:num_ts
    d1=data(i,:);
    for j=i+1:num_ts
        d2=data(j,:);
        dist(i,j)=sqrt(abs(d1-d2)*abs(d1-d2)'/dim);
    end
end

dist=dist+dist';